package io.kiki.sba.registry.server.clientInterface.limit;

import com.google.common.util.concurrent.RateLimiter;
import io.kiki.sba.registry.server.clientInterface.bootstrap.Config;


public class AccessLimitServiceImpl implements AccessLimitService {

    private RateLimiter rateLimiter;

    public AccessLimitServiceImpl(Config config) {
        rateLimiter = RateLimiter.create(config.getAccessLimitRate());
    }

    @Override
    public boolean tryAcquire() {
        return rateLimiter.tryAcquire();
    }
}
